package hnyj

import (
	"github.com/gin-gonic/gin"
	"yak.admin/src/middleware"
	"yak.admin/src/module/backend/hnyj/controller"
	"yak.admin/src/module/backend/hnyj/repository"
)

func Routers(group *gin.RouterGroup) {
	// ==============
	group.GET("/", controller.Home)
	// 关注、取消关注
	group.POST("/report-watch", controller.Watch)
	group.POST("/report-unwatch", controller.Unwatch)
	// 上报
	group.GET("/report-ready", controller.Ready)
	group.POST("/report-ready", controller.ReadyList)
	group.GET("/report-ready/view", controller.ReadyView)
	// 历史上报
	group.GET("/report-history", controller.History)
	group.POST("/report-history", controller.HistoryList)
	group.GET("/report-history/view", controller.HistoryView)
	group.GET("/report-history/excel", controller.HistoryExcel)
	// 风险汇总
	group.GET("/report-summary", controller.Summary)
	group.POST("/report-summary", controller.SummaryList)
	group.GET("/report-summary/view", controller.SummaryView)
	group.GET("/report-summary/excel", controller.SummaryExcel)
	// 用户
	group.GET("/users", func(c *gin.Context) {
		repos := repository.UserRepository{}
		c.Set("Page", middleware.Page{
			Title: "用户管理", Linker: "users", Tpl: "hnyj/user/index.tpl", Header: "用户列表",
			Data: map[string]interface{}{"StatusLabels": repos.StatusLabels(),},
		})
	})
	group.POST("/users", controller.Users)
	group.POST("/user-checked", controller.Checked)
	group.POST("/user-del", controller.Remove)
	group.GET("/user-excel", controller.UsersExcel)
	// 讨论
	group.GET("/discuss-category", func(c *gin.Context) {
		c.Set("Page", middleware.Page{
			Title: "用户咨询", Linker: "discuss-category", Tpl: "hnyj/discuss/index.tpl", Header: "咨询列表",
		})
	})
	group.POST("/discuss-category", controller.DiscussCategory)
	group.POST("/discuss-category/wanjie", controller.Wanjie)
	group.GET("/discuss-detail", func(c *gin.Context) {
		pid, _ := c.GetQuery("pid")
		c.Set("Page", middleware.Page{
			Title: "用户咨询", Linker: "discuss-category", Tpl: "hnyj/discuss/detail.tpl", Header: "咨询列表",
			Data: map[string]interface{}{"pid": pid},
		})
	})
	group.POST("/discuss-detail", controller.Discusses)
	group.GET("/discuss-detail/view", controller.DiscussView)
	return
}
